﻿@using Nxg.Blog.Core.Extensions
@model Nxg.Blog.Core.ViewProjections.Home.RecentBlogPostsViewModel

@{
    var postGroup = Model.Posts.GroupBy(x => x.PubDate.Date);
}
<div class="main">
    <div class="post-wrap archive">
        @foreach (var pg in postGroup)
        {
            <h3>@pg.Key.ToShortDateString()</h3>
            foreach (var blogPost in pg)
            {
                <article class="archive-item">
                    <a class="archive-item-link" href="@blogPost.GetLink()">@blogPost.Title</a>
                    <span class="archive-item-date">@blogPost.PubDate.ToString("yyyy-MM-dd HH:mm")</span>
                </article>
            }
        }
        <ul class="pagination">
            @for (var i = 1; i <= Model.PageCount; i++)
            {
                <li>
                    @if (i != Model.Page)
                    {
                        <a class="page-number" href="/page/@i/">@i</a>
                    }
                    else
                    {
                        <span class="page-number current">@i</span>
                    }
                </li>
            }
        </ul>
    </div>
</div>